package com.atxiaodei.kabudashejimoshi.责任链模式.校验不用设计模式;


import com.atxiaodei.kabudashejimoshi.责任链模式.Member;
import org.apache.commons.lang.StringUtils;

public class MemberService {

    public void login(String userName,String passWord){

        if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(passWord)) {
            System.out.println("用户名密码不能为空！");
            return ;
        }

        System.out.println("用户名密码不为空，可以往下执行");

        Member member = checkExists(userName, passWord);

        if (member==null) {
            System.out.println("用户不存在");
            return ;
        }
        System.out.println("登陆成功，可以往下执行");
        if (!"admin".equals(member.getRoleName())) {
            System.out.println("不是管理员，没有操作权限");
        }
        System.out.println("你好admin，可以继续操作");


    }

    private Member checkExists(String userName,String passWord){

        Member member=new Member(userName,passWord);

        member.setRoleName("admin");

        return member;
    }
}
